# pattern = Regexp.new("(.{10})(#{ARGV[0]})(.{10})")
pattern = Regexp.new(ARGV[0])
filename = ARGV[1]

count = 0
File.open(filename) do |f|
  f.each_line do |line|
    if pattern =~ line
      line.scan(pattern) do |s|
        count += 1
        pre = $`
        post = $'
        puts "#{pre[-10, 10]}<<#{s}>>#{post[0, 10]}"
      end
      # puts line
      # print line.gsub(pattern){ |str| "<<#{str}>>" }
    end
  end
end
puts "count:#{count}"